import { RecorderStatus } from '@renderer/types/enums/recoder.enum'
import { defineStore } from 'pinia'

export const useImChatStore = defineStore('imChat', {
  state: () => ({
    recordStatus: RecorderStatus.READY, // 录制状态:   已经开始 已经暂停  已完成 已就绪(权限已经拿到了)
    isVideoMode: false, //当前录制模式:  视频 音频
    mediaStream: undefined as MediaStream | undefined, //媒体流
    mediaRecorder: undefined as MediaRecorder | undefined // 媒体录制器
  }),
  actions: {
    // 设置录制状态
    setRecordStatus(status: RecorderStatus) {
      this.recordStatus = status
    },
    // 切换模式
    toggleMode(status: boolean) {
      this.isVideoMode = status
    },
    setMediaStream(stream: MediaStream | undefined) {
      this.mediaStream = stream
    },
    setMediaRecorder(recorder: MediaRecorder) {
      this.mediaRecorder = recorder
    }
  }
})
